package cn.scnu.controller;

import cn.scnu.common.model.ResponseResult;
import cn.scnu.model.dto.GrowthRateDTO;
import cn.scnu.model.dto.MonthCountDTO;
import cn.scnu.model.dto.RegionCountDTO;
import cn.scnu.model.dto.XmlxCountDTO;
import cn.scnu.service.IClipgeometry2Service;
import cn.scnu.service.IProjectAcceptanceService;
import cn.scnu.service.IWarchivesStorageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 可视化大屏接口
 *
 * @author hqz
 * @className WarchivesStorageController
 * @createTime 2024年11月22日 16:25:00
 */
@RestController
@RequestMapping("/StatisticalInfo")
@RequiredArgsConstructor
@Slf4j
@Api(tags = "可视化大屏接口(废弃)")
public class WarchivesStorageController {

    private final IWarchivesStorageService warchivesStorageService;

    private final IProjectAcceptanceService projectAcceptanceService;

    private final IClipgeometry2Service clipgeometry2Service;

    @ApiOperation(value = "项目各类型数量统计")
    @GetMapping("getXmlxCount")
    public ResponseResult<List<XmlxCountDTO>> getXmlxCount() {
        return ResponseResult.success(warchivesStorageService.getXmlxCount());
    }

    @ApiOperation(value = "项目数量统计")
    @GetMapping("getXmCount")
    public ResponseResult<Long> getXmCount() {
        return ResponseResult.success(warchivesStorageService.getXmCount());
    }

    @ApiOperation(value = "基地面积总量统计")
    @GetMapping("getJdmjCount")
    public ResponseResult<Double> getJdmjCount() {
        return ResponseResult.success(projectAcceptanceService.getJdmjCount());
    }

    @ApiOperation(value = "总建筑面积统计")
    @GetMapping("getZjzmjCount")
    public ResponseResult<Double> getZjzmjCount() {
        return ResponseResult.success(projectAcceptanceService.getZjzmjCount());
    }

    @ApiOperation(value = "总建筑楼高统计")
    @GetMapping("getJzgdCount")
    public ResponseResult<Double> getJzgdCount() {
        return ResponseResult.success(projectAcceptanceService.getJzgdCount());
    }

    @ApiOperation(value = "以f_wtrq字段作为时间，以年份、f_czg作为查询条件，查询指定年份每月项目数量情况")
    @GetMapping("getMonthCount")
    public ResponseResult<List<MonthCountDTO>> getMonthCount(@RequestParam Integer year, @RequestParam(required = false) String czg) {
        return ResponseResult.success(warchivesStorageService.getMonthCount(year, czg));
    }

    @ApiOperation(value = "各类型项目年度增长率")
    @GetMapping("getYearGrowthRate")
    public ResponseResult<List<GrowthRateDTO>> getYearGrowthRate(@RequestParam(required = false) String czg) {
        return ResponseResult.success(warchivesStorageService.getYearGrowthRate(czg));
    }

    @ApiOperation(value = "各地区项目数量统计")
    @GetMapping("getRegionCount")
    @Cacheable("getRegionCount")
    public ResponseResult<List<RegionCountDTO>> getRegionCount() {
        return ResponseResult.success(clipgeometry2Service.getRegionCount());
    }
}